<template>
	<view>
		<!-- 顶部导航 -->
		<fa-navbar title="设置"></fa-navbar>
		<u-cell-group>
			<u-cell-item icon="account-fill" title="会员中心" @click="openPage(0)"></u-cell-item>
			<u-cell-item icon="edit-pen-fill" title="修改资料" @click="openPage(1)"></u-cell-item>
			<u-cell-item icon="lock-opened-fill" title="修改密码" @click="openPage(2)"></u-cell-item>
			<u-cell-item icon="backspace" title="注销登录" @click="openPage(3)"></u-cell-item>
		</u-cell-group>
		<!-- 底部导航 -->
		<fa-tabbar></fa-tabbar>
	</view>
</template>

<script>
import { mapState} from 'vuex';
export default {
	computed: {
		...mapState(['user'])
	},
	data() {
		return {};
	},
	methods: {
		openPage: async function(index) {
			if (index == 3) {
				//退出登录
				let res = await this.$api.getUserLogout();
				if (!res.code) {
					this.$u.toast(res.msg);
					return;
				}
				//退出成功
				this.$u.vuex('vuex_user', { avatar: '' }); //清除vuex_user
				this.$u.vuex('vuex_token', ''); //清除用户token
				this.$u.vuex('vuex_isAdmin', false); //清除用户管理员
				this.$Router.back(1);
				return;
			}
			let p = ['/pages/community/setting/myinfo', '/pages/user/setting/user', `/pages/user/auth/validcode?event=resetpwd&mobile=${this.user.mobile}&type=1`];
			this.$wanlshop.to(p[index]);
		}
	}
};
</script>

<style></style>
